package com.research.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.research.common.R;
import com.research.entity.GoodProject;
import com.research.service.GoodProjectService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goodProject")
public class GoodProjectController {

    @Resource
    private GoodProjectService goodProjectService;

    @GetMapping("list")
    public R list(String keyword) {
        return R.success(goodProjectService.list(
                new QueryWrapper<GoodProject>().like(keyword != null,"project_name", keyword)
        ));
    }

    @PostMapping("save")
    public R save(@RequestBody GoodProject goodProject) {
        return R.success(goodProjectService.save(goodProject));
    }

    @PostMapping("update")
    public R update(@RequestBody GoodProject goodProject) {
        return R.success(goodProjectService.updateById(goodProject));
    }

    @PostMapping("delete")
    public R delete(Integer id) {
        return R.success(goodProjectService.removeById(id));
    }

    @GetMapping("detail")
    public R detail(Integer id) {
        return R.success(goodProjectService.getById(id));
    }
}